route.js 651 B

12345678910111213141516171819202122232425
  1. // app/api/branches/[branch]/[year]/months/route.js
  2. import { NextResponse } from "next/server";
  3. import { listMonths } from "@/lib/storage";
  4. export async function GET(request, { params }) {
  5. const { branch, year } = params;
  6. if (!branch || !year) {
  7. return NextResponse.json(
  8. { error: "branch oder year fehlt" },
  9. { status: 400 }
  10. );
  11. }
  12. try {
  13. const months = await listMonths(branch, year);
  14. return NextResponse.json({ branch, year, months });
  15. } catch (error) {
  16. console.error("[api/branches/[branch]/[year]/months] Fehler:", error);
  17. return NextResponse.json(
  18. { error: "Fehler beim Lesen der Monate" },
  19. { status: 500 }
  20. );
  21. }
  22. }